<template>
  <div class="device-box">
    <el-form>
      <template v-for="(item, index) in formList">

        <el-form-item
          :key="`${item.prop}${index}`"
          :style="item.itemStyle || {}"
          :label="item.name"
          :class="item.itemClass"
        >
          {{ formData[item.prop] }}
        </el-form-item>
      </template>
    </el-form>
  </div>
</template>

<script>
import { dictMixin } from '@/mixin/dict'
import api from '@/api/apis/sceneRoom'
import { parseSceneData } from '@/utils/scene-data'

export default {
  name: 'DeviceDetail',
  mixins: [dictMixin],
  props: {
    // 请求参数
    requestParams: {
      type: Object,
      default: () => ({})
    },
    // 弹窗数据
    popData: {
      type: Object,
      default: () => ({})
    },
    // 弹窗配置
    popConfig: {
      type: Object,
      default: () => ({})
    },
    // 弹窗取消
    close: {
      type: Boolean,
      default: false
    },
    // 弹窗确认
    confirm: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formData: {},
      formList: [
        {
          name: '设备编码',
          prop: 'deviceCode'
        },
        {
          name: '设备名称',
          prop: 'deviceName'
        },
        {
          name: '设备类型',
          prop: 'deviceTypeName'
        },
        {
          name: '当前状态',
          prop: 'deviceStatusName'
        },
        {
          name: '是否重点关注设备',
          prop: 'isFocusName'
        },
        {
          name: '产品类型',
          prop: 'productTypeName'
        },
        {
          name: '所属项目',
          prop: 'projectName'
        },
        {
          name: '所属场景',
          prop: 'sceneInfoName'
        },
        {
          name: '具体位置',
          prop: 'position'
        },
        { name: '' },
        {
          name: '备注',
          prop: 'remark'
        }
      ]
    }
  },
  watch: {
    popData: {
      handler(data) {
        this.formData = data
      },
      deep: true,
      immediate: true
    },
    confirm() {
      this.$emit('onFinish', 'device-detail')
    },
  }
}
</script>

<style lang="scss" scoped>
.device-box {
  color: #333;
  padding: 0 20px;

  ::v-deep .el-form {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;

    .el-form-item {
      width: calc(50% - 10px);

      &.width100p {
        width: 100%;
      }

      .el-form-item__label {
        color: #666;
        font-size: 14px;
      }

      &.form-sub-title {
        width: 100%;

        .el-form-item__label {
          display: flex;
          align-items: center;
          justify-content: flex-start;
          font-weight: bold;
          color: #333;
          font-size: 16px;
          line-height: 1;

          &::before {
            content: '';
            display: inline-block;
            width: 4px;
            height: 15px;
            background-color: #00858d;
            margin-right: 5px;
          }
        }
      }
    }

    .el-select,
    .el-cascader {
      width: 100%;
    }
  }
}
</style>
